/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.nail.zhaogr.model;

import javacommon.base.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "my_favorite")
public class MyFavorite extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "MyFavorite";
	public static final String ALIAS_FAVORITE_ID = "favoriteId";
	public static final String ALIAS_MEMBER_ID = "memberId";
	public static final String ALIAS_PUBLISH_INFO_ID = "publishInfoId";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * favoriteId       db_column: favoriteId 
     */ 	
	
	private java.lang.Long favoriteId;
    /**
     * memberId       db_column: memberId 
     */ 	
	
	private java.lang.Long memberId;
    /**
     * publishInfoId       db_column: publishInfoId 
     */ 	
	
	private java.lang.Long publishInfoId;
	//columns END


	public MyFavorite(){
	}

	public MyFavorite(
		java.lang.Long favoriteId
	){
		this.favoriteId = favoriteId;
	}

	

	public void setFavoriteId(java.lang.Long value) {
		this.favoriteId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "favoriteId", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getFavoriteId() {
		return this.favoriteId;
	}
	
	@Column(name = "memberId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMemberId() {
		return this.memberId;
	}
	
	public void setMemberId(java.lang.Long value) {
		this.memberId = value;
	}
	
	@Column(name = "publishInfoId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getPublishInfoId() {
		return this.publishInfoId;
	}
	
	public void setPublishInfoId(java.lang.Long value) {
		this.publishInfoId = value;
	}
	
	
	private PublishInfo publishInfo;
	public void setPublishInfo(PublishInfo publishInfo){
		this.publishInfo = publishInfo;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "publishInfoId",nullable = false, insertable = false, updatable = false) 
	})
	public PublishInfo getPublishInfo() {
		return publishInfo;
	}
	
	private Members members;
	public void setMembers(Members members){
		this.members = members;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "memberId",nullable = false, insertable = false, updatable = false) 
	})
	public Members getMembers() {
		return members;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("FavoriteId",getFavoriteId())
			.append("MemberId",getMemberId())
			.append("PublishInfoId",getPublishInfoId())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getFavoriteId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof MyFavorite == false) return false;
		if(this == obj) return true;
		MyFavorite other = (MyFavorite)obj;
		return new EqualsBuilder()
			.append(getFavoriteId(),other.getFavoriteId())
			.isEquals();
	}
}

